home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 1 (Walnut Creek)
/
Aminet - June 1993 [Walnut Creek].iso
/
usenet
/
sources
/
volume91
/
shells
/
cshel510
/
part04
/
csh.doc.aa
< prev
Wrap
Text File
|
1991-04-16
|
26KB
|
701 lines
INSTRUCTIONS FOR SHELL VERSION: 5.10 11-Apr-1991
=================================================
Contents
--------
O. Installation
I. Description
II. Overview of Major features
III. Restrictions
IV. PIPES
V. Command Pre-processor
VI. Command Line Editing
VII. Function Keys
VIII. Shell Commands
IX. Special Set Variables
X. Functions
XI. Miscellaneous
XII. Example source files
XIII. Default values
XIV. Object oriented features
XV. Keymaps
O. Installation
----------------
You can simply invoke csh from the command line or at the end of your
startup-sequence, because csh is, from the AmigaDOS standpoint, not a true
shell like l:shell-seg. Nevertheless, csh is 'pure', so if your archiver
forgot to set the 'p' bit, do it right now.
Proposed final setup: If you want to make csh resident, do the following:
Kickstart 1.3
1. Copy csh anywhere on your (hard)disk, e.g. dh1:tools
2. Make sure your s:startup-sequence contains:
Resident CLI L:Shell-Seg SYSTEM PURE ADD
Resident dh1:tools/csh ADD
NewCLI FROM s:csh-startup
EndCLI
3. Put the following in s:csh-startup
csh -r s:firstlogin.sh
4. In s:firstlogin.sh, put any commands to be called only once, like setmap,
assign, setclock. This is a shell script, use # for comments, and don't
use .key type commands. At the end of this file, add
source s:login.sh
5. In s:login.sh, you put any commands that need to be invocated on every
invocation, like 'alias', 'set' and so on.
6. Put the following the s:cli-startup and s:shell-startup, so csh will be
started in any window opened by NewCLI or from workbench.
csh s:login.sh
Kickstart 2.0
1. Copy csh anywhere on your (hard)disk, e.g. dh1:tools
2. Make sure your s:startup-sequence contains:
Resident dh1:tools/csh ADD
csh s:firstlogin.sh
3. Proceed from step 4 in kickstart 1.3
Additionally, I recommend to assign CSH: somewhere and put your docs and
cshell scripts there. You can do the assign from inside the shell, it's not
needed at startup.
I. DESCRIPTION
---------------
This version of Shell is the successor of:
Shell V2.04 (C)Copyright 1986, Matthew Dillon, All Rights Reserved
Shell V2.04M-V2.07M by Steve Drew
Shell V2.08MI, V3.xxA and V4.xxA by Carlo Borreo & Cesare Dieni
Shell V5.xxL by Urban Mueller
If you have any wishes, bug reports or beer bottles, send them to:
FIDONET : AUGL BBS, 2:302/906
INTERNET: umueller@iiic.ethz.ch
or
Urban Mueller
Schulhausstrasse 83
CH-6312 Steinhausen
SWITZERLAND
Any sign of intelligent life welcome!
Please check the 'restrictions' and 'known bugs' paragraphs before reporting
any bugs. The support BBS is AUGL, +41 75 8 20 19, +41 75 8 20 18, +41 75 2
15 87 (all lines USRobotics HST) login='cshell', password='support'
For versions prior to 5.00 send suggestions/criticism/anything else to Carlo
Borreo or Cesare Dieni at:
BITNET: PERUGIA@ICNUCEVM.BITNET
FIDONET: 2:332/602.0@FIDONET
or
Carlo Borreo Cesare Dieni
Via G. Berio 34 Via G. Taddei 3
I-18100 Imperia I-56100 Pisa
Italy Italy
You may distribute this program unmodified and for non-profit only.
*** YOU MAY NOT MODIFY THIS PROGRAM AND REDISTRIBUTE IT ***
If everyone writes his own version of Shell and distributes it, we would be
covered by Shell versions. If you make a modification to Shell that you
would like to share with other users, please send us a DIFF output, or a
description of what you need.
CREDITS
-------
Arexx is a program by William Hawes.
Cygnus Ed Professional (C) 1988 CygnusSoft Software.
Many thanks to all who gave me feedback, namely Eddy Carroll, Patrizio
Rusconi, Allard Siemelink, Magnus Heldestad, Roddi Walker, Roy Haverman,
Steve Koren, Randell Jesup and all I forgot to mention.
II. OVERVIEW
------------
Shell provides a convenient AmigaDos alternative command interface. All its
commands are internal and thus does not rely on the c: commands for any
functionality.
Major features include:
- command line editing
- simple history
- piping
- aliases with arguments
- variables & variable handling (embedded variables)
- file name expansion via wild carding ('?', '*' and more)
- conditionals (if/else etc..)
- source files (w/ gotos and labels)
- tab file name completion
- object oriented features (file classes, actions)
- many built in commands to speed things up
- full functionality on VT terminals
- freely programmable command line editing
Shell runs on minimum stack, for recursive aliases and source files better
increase stack to 8K or more.
If you use CShell for the first time, remember the following:
- CShell internal commands must be lowercase & can be abbreviated
- AmigaDOS command 'Execute' causes some trouble. You cannot redirect
it, you must not rename it, and you get no return code.
You can also use 'source' to start your scripts, but you'll have
to rewrite them a bit. Besides the '.key'-type commands, 'source'
is downward compatible with 'Execute'.
- You can always get more information on a command if csh.doc is
in the current directoy or in csh: (you will be able to modify
this) and you enter 'man <command>'
III. RESTRICTIONS
-----------------
The following applies only to Kickstart 2.0, and only to V36: The INTERNAL
commands cannot be started. The same is true for the commands in C: if they
were made resident using the AmigaDOS 'Resident' command (with cshell's
'resident' they work). Thus, you should disable the INTERNAL residents using
the -i0 startup option if you have a V36 Kickstart.
Under 1.3, you can't start AmigaDOS residents directly. But you can use the
-r startup option, which will copy the AmigaDOS resident list to the arp
resident list once (and make those residents unremovable). I'll try to find
a better solution.
The best choice under both kickstarts is to make only csh itself AmigaDOS
resident, all other commands, if any, ARP resident. Under 1.3, you can start
the shell (as any other commands) from the resident list only after you did
'resident CLI l:Shell-seg' and 'newcli'.
The c:Execute command cannot be redirected, does not return error codes, and
might cause other problems. It will not work at all if it has been renamed.
The VDK: handler and Frank Seidel's BootRam-Handler have a bug with setting
file dates, so when using the copy command you should try the -d and -p
switches, otherwise your file date will be bad. (This is not a shell bug)
If using with conman it you may consider starting shell with the -a switch to
turn off shell's command line editing and use conmans instead. You'll lose,
however, many shell features like TAB file name completion.
CB-handler (a tool that installs a scrollbar in the CLI window) is not 100%
compatible with cshell. The log will not always represent the real screen
contents.
IV. NOTES ON PIPES
------------------
PIPES
PIPES have been implemented using temporary T: files. Thus, you
should be careful when specifying a 't:*' expansion as it might
include the temporary files. These files are deleted on completion
of the pipe segment.
The file names used are completely unique, even with multiple shell
running simultaneously.
My favorite new feature is the fact that you can now redirect to
and from, and pipe internal commands. 'echo charlie >ram:x', for
instance. Another favorite:
echo "echo mem | csh" | csh
No BCPL program should be output-append redirected (>>).
V. COMMAND PRE-PROCESSOR
-------------------------
PREPROCESSING
Preprocessing is done on the command line before it is passed on to
an internal or external routine:
^c where c is a character is converted to that control character.
Thus, say '^l' for control-l.
\233 insert character code 233 octal. Do not use values between
200o and 232o, as they have special meanings. \240 is the
word separator.
$name where name is a variable name. Variable names can consist of
0-9, a-z, A-Z, and underscore (_). The contents of the
specified variable is used. If the variable doesn't exist,
the specifier is used. That is, if the variable 'i' contains
'charlie', then '$i' -> 'charlie'. If the variable 'i' doesn't
exist, then '$i'->'$i' .
; delimits commands. echo charlie ; echo ben.
' ' (a space). Spaces delimit arguments.
"string" a quoted string. Trailing quotes are optional. For instance,
if you want to echo five spaces and an 'a':
echo a -> a
echo " a" -> a
\c overide the meaning of special characters. '\^a' is a
circumflex and an a rather than control-a. To get a backslash,
you must say '\\'.
also used to overide alias searching for commands.
>file specify output redirection. All output from the command is
placed in the specified file.
>>file specify append redirection (Does not work with BCPL programs).
<file specify input redirection. The command takes input from the
file rather than the keyboard (note: not all commands require
input; it makes no sense to say 'echo <charlie' since
the 'echo' command only outputs its arguments).
| PIPE specifier. The output from the command on the left becomes
the input to the command on the right. The current SHELL
implimentation uses temporary files to store the data.
!! execute the previously executed command.
!nn (nn is a number). Insert the history command numbered n (see
the HISTORY command)
!partial search backwards through the history list for a command which
looks the same as 'partial', and execute it.
# enter comment. The rest of the line is discarded (note: \#
will, of course, overide the comment character's special
meaning)
{e hi;e ho} executes two commands as one, so they can be redirected
as one, so they can be redirected together (see ALIAS
command). The traling curly brace is optional.
$(foo) insert the stdout of the command 'foo' at this position of
the command line. Every line of the output will count as one
argument. The closing parenthesis is optional.
`foo` insert the stdout of the command 'foo' at this position of
the command line. Every blank separated word will count as
one argument. The trailing backtick is optional.
Please note the subtle differences between
alias count {echo one;echo two}
alias count "echo one;echo two
The first form will create an alias that contains a local alias. The
other will create a plain alias. Also, things within braces will not
be parsed more than once, therefore a backslash needs not be pre-
ceeded by a pair of backslashes. Thus the commands look the same as
if they were to be typed in at the prompt. To echo lots of '#',
either use:
forever {echo \#
forever "echo \\\#
A block can spread over several line. Refer to the SOURCE command.
VI. COMMAND LINE EDITING
------------------------
o Command line can be up to 255 chars.
o Inserts and deletes are handled correctly over multiple screen
lines.
o Shell will keep track of the line width should the window get
resized.
EDITING
-- MOVING --
Left Arrow One character left
Right Arrow One character right
Shift-Left Arrow One word left
Shift-Right Arrow One word right
ESC-Left Arrow Beginning of line (^A) (^Z)
ESC-Right Arrow End of line (^E)
-- DELETING --
Backspace Previous character
Del Character under cursor
ESC-Backspace Previous word (^W)
ESC-Del Next word
ESC-x-Backspace To start of line (^B)
ESC-x-Del To end of line (^K)
ESC-d Entire line (^X)
-- HISTORY --
Up Arrow Recall previous commands
Down Arrow Recall commands
Shift-Up Arow Get history from partial (or number)
Shift-Down Arrow Go below last command of history
ESC-Up Arrow Get start of history
ESC-Down Arrow Get end of history
ESC-! Get history from partial (or number)
^T Insert tail (all but first word) of previous line
^P Duplicate previous word (useful for mv)
-- COMPLETION --
TAB Inserts first matching file name
Shift-TAB Inserts longest common substring
ESC-TAB Inserts all matching file names
ESC-c Does a quick cd on left word (TAB for cycling)
ESC-~ Inserts the last current directory
-- EXECUTING LINE --
Return Executes line
ESC-Return Executes this line of history & brings up next one
^N Next line. Don't exec this one but store history
^\ EOF (directly exits)
-- MISCELLANEOUS --
^L Retype current line.
^O Echo a ^O
^R Repeat last command (don't play with this)
^U Undo/Redo last edit
ESC-i Toggle Insert/Overwrite
f1-f10 Execute command if variable exists.
F1-F10 More commands (Shifted f keys).
Help Invokes help command
Whenever the cursor is placed on or directly after an incomplete file name
and you press TAB, CShell inserts for the first filename (sorted
alphabetically) that matches the name part already typed. Any wildcards
are allowed here, if none are given, '*' is appended. Immediately pressing
TAB again brings up the next file name that matched the substring.
Shift-TAB will only insert the as much as is common to all files that
matched you abbreviation. If pressed again, behaves just like TAB.
ESC-Tab inserts the name of the directory where you would have ended up
with a quick cd to that substring.
Note that ^D now means 'quit batchfile' like under AmigaDOS and is no
longer used for quitting CShell. If you want it back, enter 'keymap 0 4=41'
The CTRL keys FGVY are unset, feel free to map them to any function (see
chapter XV). You can also remap all preset keys.
VII. FUNCTION KEYS
------------------
FUNKEY
Function keys now insert text to the current position on the command
line. They maybe terminated with a ^M (return). f1 would be non shifted
where as F1 is shifted.
Most of functions key have a default definition, but it may be changed.
$ set f1 dir df0:^M
will add the text 'dir df0:<return>' to the current line.
$ set f1 dir
would only add 'dir' you could then enter ' df0:<return>'
VIII. SHELL COMMANDS
--------------------
STARTUP OPTIONS
First to start shell from a CLI:
shell [-abcfiknstv] [-c command;command]
shell [-abcfiknstv] [batchfile1 ... batchfileN]
-a AUX: mode. No command line editing and text highlighting
-b starts shell in background, which means only task priority -1.
-c allows execution of one command line and then exits out
of shell. This is useful for running an internal shell
commands in the background or from an external application:
Run csh -c "dir df0:; copy -r df0: df1: >nil:; echo Done"
-f starts shell in foreground, which means only task priority 1.
you might reset this prioritiy to 0 at the end of your .login
-i0 disables INTERNAL residents. for V36 kickstarts.
-k sets _nobreak before doing anything
-n suppresses starting of s:.login
-r copies the amiga resident list to the arp resident list. You
can't remove them anymore. No copying when under kick 2.0 or
if arp residents present.
-s globally enables the star '*' as alias for #? in AmigaDOS 2.0
-t terminal mode. You can use command line editing and text high-
lighting on a VT100 compatible terminal.
-v sets _verbose to 'hs' before doing anything.
Under 1.3, the best thing you can do is to make csh resident using
the AmigaDOS Resident command in the startup-sequence, then start
it with the option -r, so you can start another resident csh from
inside csh. NOTE: Residents copied using -r cannot be removed! I
advise you to use the internal resident command for all but csh
itself.
COMMAND EXECUTION
Internal shell commands are case sensitive and may be abreviated.
The first argument is the command-name... here is (in order) how Shell
tries to execute it:
1) The alias list is searched for an alias with an exactly
matching name.
2) Internal commands list is scanned for a command even partially
matching name (so you can, for instance, say resi for resident;
however, you should specify enough of a command to be unique).
3) Then, the list of functions is scanned for a command that
matches completely. If one is found, the result of the function
is echoed to stdout.
4) Now the command is assumed to be external. Arguments with spaces
or empty strings will be surrounded by quotes.
5) If the file is a directory, a 'cd <file>' will be performed to
it.
6) AmigaDOS and ARP resident list are scanned for it (you can use
Shell's 'resident' command to add/remove a file in the ARP list).
7) If the file is in the current directory and it's executable, it
is started.
8) Then it is searched in the AmigaDOS path and c: (NOTE: Path
assigns to C: under Kickstart 2.0 don't work; use 'path')
9) Now, the shell path ($_path) is searched. If it's found and
executable, it's be started. If it has the 's' bit set, it will
be 'c:Execute'd.
10) If there exists a file with the suffix '.sh' and the same root
in the current directory or in the shell path, it is 'source'd.
11) Then the variable _rxpath is examined. If there exists a file
with the suffix '.rexx' and the same root in the current direc-
tory or in '$_rxpath', 'RX <file>' will be performed.
12) If all failed, an 'exec' action is sent to the file. See chapter
XIV for more info on classes and actions.
To enforce that the external 'dir'-command is used, enter 'Dir'. Tt
is a good habit to uppercase the first letter of all external com-
mands, even if this is not necessary.
AUTOMATIC SOURCING may be accomplished by naming shell scripts with
a .sh suffix. Thus, if you say 'stuff' and the file 'stuff.sh'
exists in your current or anywhere in Shell search path (NOTE: won't
be found in the AmigaDOS path), it will be SOURCED with all arguments
you have given placed in the $_passed variable. This is equivalent
to typing 'source stuff.sh'
WILD CARD EXPANSION
Most shell commands will accept multiple arguments that can
be as a result of wild card expansion. Also when calling
an external command shell will first expand any wild cards
to separate arguments. If you wish to have the external command
handle it's own wild carding you will need to insert quotes
around the special wild card characters or use an alias (see
explanation of 'alias')
eg.
arc a new.arc *.txt - shell will expand and pass to arc
arc a new.arc "*.txt" - let arc expand the wild cards.
alias arc "*a Arc $a" - now shell will never expand
Wildcards allowed:
? match any single character
* match any string
.../* recursive search down ALL sub directories from current level
~ exclude pattern matching specifier
! synonym for ~, supported for compatibility
& prefixed to patterns, ask confirmation for each file
[] character class
~ the previous current directory (if separated)
Note that a pattern must contain a '?' or a '*', otherwise the other
special characters are not recognized. Furthermore, you cannot spe-
cify a single '?' as a pattern in the first argument to a command,
as this will be passed on to the command in order to show its usage.
Examples:
df0:.../* all files in all directories on df0:
df0:.../!*.info full directory tree of df0: but exclude
any ugly .info files.
!*.o !*.c will result in ALL files matching since what
doesn't match the !*.o will match the !*.c
df1:&* all files in root of df1:, but ask
confirmation for each
*.[co] all files ending in .c or .o
~*.[co] all files NOT ending in .c nor in .o
~ the previous current directory
~/*.c all .c files in the previous current directory
~// the parent of the previous current directory
. the current directory
./foo.c the same as foo.c
.. the parent of the current directory
../foo.c the file foo.c in the parent directory
Note that some commands prevent wild card expansion. These are:
- dir, rpn, whereis, window
Those commands will expand the wild cards themselves. This is why
dir @without( *.? , *.o )
will not work. Instead use:
set arg @without( *.? , *.o );dir $arg
There is one exception to the rules given above: A single '?' as
the first argument will *not* expand in order to allow you to get
the usage of CLI and csh commands easily.
The following symbols are not yet supported by wild card
expansions, but are accepted in search -w:
( | ) OR matching
# 0 or more times the pattern following
Examples:
"k#a" matches ka, kaa, kaaa, etc.
"hel(lo|p)" matches hello or help.
LIST OF COMMANDS:
-----------------
ABORTLINE
Usage : abortline
Example : echo a;abort;echo b
Results : a
Causes the rest of the line to be aborted. Intended for use in
conjunction with exception handling.
ACTION
Usage : action [-a] actionname file [arguments]
Sends an action to a file. See chapter XIV CLASSES
Options:
-a (abort) returns 0 if failed and 1 if successful. Otherwise,
normal error codes (10 or 11) are returned
ADDBUFFERS
Usage : addbuffers drive buffers [drive buffers ...]
Example : addbuffers df0: 24
Just like AmigaDOS addbuffer command, causes new buffers to be
allocated for disk I/O. Each buffer costs 512 bytes of memory,
CHIP memory if a disk drive.
ALIAS
Usage : alias [name [command string] ]
Example : alias vt "echo Starting VT100;run sys:tools/vt100"
Sets a name to be a string. You can alias a single name to a set
of commands if you enclose them in quotes as above. By simply
typing vt, the command line above would be executed.
Aliases may call each other, but direct recursion is prohibited,
so the following works: alias ls "ls -s"
To prevent alias replacement, enter: \ls
By typing "alias name", you will get the alias for that name, while
with "alias" you get a list of all alias.
ARGUMENT PASSING TO AN ALIAS:
Usage : alias name "%var[%var...] [ command_string ]"
alias name "*var[%var...] [ command_string ]"
Example : alias xx "%q%w echo hi $q, you look $w
xx Steve great today
Results : hi Steve, you look great today
The second form of the alias command allows passing of arguments
to any position within the command string via use of a variable
name. To pass arguments to the end of a command string this method
is actually not necessary. These variables are local, so they don't
destroy another variable with the same name.
If you specify multiple arguments, every argument will be assigned
one word, and the last argument will be assigned the rest of the
command line.
Using a '*' instead of the first '%' prevents wild card expansion:
alias zoo "*a zoo $a
To expand the wild cards after you got them, use
exec set a $a
IMPLICIT ALIASES:
Usage : {command;command}
{%var command;command} arg arg
Example : {%tmp echo $tmp $tmp} hello
Results : hello hello
Curly braces define a temporary aliases. They can be redirected as
a whole, can have arguments and local variables. They count as
one argument, even if there are blanks inside (as with quotes), and
they may be nested. Complex alias definitions can use the braces
instead of quotes, although this will add some calling overhead.
The closing curly brace is optional if at the end of line.
Example:
alias assert {e "Are you sure? ";input -s sure
ASCII
Usage : ascii
ascii string
If called without arguments, ascii outputs a complete ascii table.
Given a string, shows each character in ascii. Options:
-h shows numbers in hexadecimal
-o shows numbers in octal
ASET
Usage : aset name value
Example : aset INCLUDE include:
Set a variable in a way that is compatible with ARP/old Aztec set
command; this is completely different from ENV: Shell variable.
ASSIGN
Usage : assign
assign logical
assign [-lnp] logical1 physical1 [logical2 physical2 ... ]
The first form shows all assigns.
The second form kills one assign.
The third form assigns logical1 to physical1 and so on. Options:
-l creates a late-binding assign under kick 2.0, normal otherwise
-n creates a non-binding assign under kick 2.0, normal otherwise
-p creates a path-assign under kick 2.0, cancelled otherwise
For definition of late/nonbinding, refer to your AmigaDOS manual.
BASENAME
Usage : basename var path
Example : basename x df0:c/Dir # sets x to "Dir"
Sets var specified to basename of path.
CAT
Usage : cat [-n][file file....]
Example : cat foo.txt
Type the specified files onto the screen. If no file is specified,
STDIN in used (note: ^\ is EOF). CAT is meant to output text files
only. Specifying -n option you will get numbered lines.
CD
Usage : cd [path]
cd -g device1 [device2 [device3 ...]]
Change your current working directory. You may specify '..' to go
back one directory (this is a CD specific feature, and does not
work with normal path specifications).
In most cases, you'll no more have to use the CD command. Just type
the desired directory at the prompt (very handy in conjunction with
file name completion). Typing a ~ alone on a command line cd's
to prevous current directory.
There are two situations left when you still need it:
Entering 'cd *tem' will cd to the first name matched.
The second form generates a list (an ascii file) of all direc-
tories on the given devices. It will be stored in the file given
in $_qcd (default: 'csh:csh-qcd'). Note that this ascii file will
not be merged but overwritten. Once you have generated this file,
you can cd to any directory on your harddisk(s) even if it's not
in the current directory.
If you have two directories of the same name and you use one of
them more, move the more important one to the beginning of the
qcd file. You might also sort the file.
It is legal to type just an abbreviation of the directory name
you want to cd to. No asterisk '*' necessary. If you end up in
the wrong directory, cd to the same directory again (best done